<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="beans.Prestador" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="jdbc.ConnectionFactory" %>
<%@ page import="java.sql.*" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Resultados da busca</title>
</head>
<body>
<%
Prestador prestador = (Prestador) session.getAttribute("prestador");
try {
	        Connection conexao = new ConnectionFactory().getConnection();
		 	PreparedStatement stmt = conexao.
	                 prepareStatement("select * from agendamento, servico, usuario " 
	                			+ "where agendamento.cd_servico=servico.cd_servico and agendamento.cd_usuario=usuario.cd_usuario " 
	                			+ "and servico.cd_prestador=" 
	                 			+ prestador.getCdPrestador() + ";");
	         ResultSet rs = stmt.executeQuery();
	 
	         while (rs.next()){
	        	 //<TABLE BORDER=2 CELLPADDING=2 bgcolor="red">
		         //<TR>
		         //<TD COLSPAN=2>Teste Nome Fantasia</TD>
		         //<TR>
		         //<TD>Servico Agendado</TD> <TD>dd/MM/yyyy hh:mm:ss</TD>
		         //</TR>
		         //</TABLE>
		         //select * from agendamento a, servico s, prestador p where a.cd_servico=s.cd_servico and s.cd_prestador=p.cd_prestador;
	         %>
	         <table border=2>
	         	<tr align="center">
	         		<td colspan=5><%out.print("<h3>" + rs.getString("ds_usuario_nome") + "</h3>");%></td>
	         	</tr>
	         	<tr>
	         		<td><%out.print(rs.getString("ds_agendamento_data_hora"));%></td>
	         		<td><%out.print(rs.getString("ds_servico_nome"));%></td>
	         	</tr>
	         </table>
	         <%
	      	}
	         rs.close();
	         stmt.close();
	     } catch (SQLException e) {
	         throw new RuntimeException(e);
	     }
%>
</html>